<?php
if (! defined ('IN_ZWS')) exit ();

class IndexAction extends Action {
	function index() {
		if (!isEmpty($_SESSION['uid']) && !isEmpty($_SESSION['ltime'])) {
			$M = M('User');
			$info = D('InfoView');
			$userInfo = $info -> where("User.id=" . $_SESSION['uid']) -> find();
			$userInfo['avatar'] = array(300 => parseAvatar($userInfo['avatar']), 100 => parseAvatar($userInfo['avatar'], 100), 50 => parseAvatar($userInfo['avatar'], 50));
			if (!$userInfo || $_SESSION['ltime'] < $userInfo['cptime']) {
				unset ($_SESSION ['uid'], $_SESSION ['username'], $_SESSION ['ltime']);
				session ('[destroy]');
				session ('[regenerate]');
				$this -> error("登录状态已失效", '/u/login');
			}
			$this -> assign('userInfo', $userInfo);
		}
		$this -> assign('siteName', setting('siteName'));
		$this -> assign('siteSubName', setting('siteSubName'));
		$this -> assign('siteDesc', setting('siteDesc'));
		$this -> display();
	}
}
